package o;

import com.huawei.hwid.core.constants.HwAccountConstants;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.Stack;

public final class gbk {
    static final String[] ˋ = new String[]{"", HwAccountConstants.BLANK, "  ", "   ", "    ", "     ", "      ", "       ", "        ", "         ", "          ", "           ", "            ", "             ", "              ", "               ", "                ", "                 ", "                  ", "                   ", "                    "};
    private static final Stack<StringBuilder> ˏ = new Stack();

    public static String ˎ(Collection collection, String str) {
        return ˋ(collection.iterator(), str);
    }

    public static String ˋ(Iterator it, String str) {
        if (!it.hasNext()) {
            return "";
        }
        String obj = it.next().toString();
        if (!it.hasNext()) {
            return obj;
        }
        StringBuilder append = ˏ().append(obj);
        while (it.hasNext()) {
            append.append(str);
            append.append(it.next());
        }
        return ˎ(append);
    }

    public static String ॱ(int i) {
        if (i < 0) {
            throw new IllegalArgumentException("width must be > 0");
        } else if (i < ˋ.length) {
            return ˋ[i];
        } else {
            char[] cArr = new char[i];
            for (int i2 = 0; i2 < i; i2++) {
                cArr[i2] = ' ';
            }
            return String.valueOf(cArr);
        }
    }

    public static boolean ˋ(String str) {
        if (str == null || str.length() == 0) {
            return true;
        }
        int length = str.length();
        for (int i = 0; i < length; i++) {
            if (!ˋ(str.codePointAt(i))) {
                return false;
            }
        }
        return true;
    }

    public static boolean ˊ(String str) {
        if (str == null || str.length() == 0) {
            return false;
        }
        int length = str.length();
        for (int i = 0; i < length; i++) {
            if (!Character.isDigit(str.codePointAt(i))) {
                return false;
            }
        }
        return true;
    }

    public static boolean ˋ(int i) {
        return i == 32 || i == 9 || i == 10 || i == 12 || i == 13;
    }

    public static boolean ˊ(int i) {
        return i == 32 || i == 9 || i == 10 || i == 12 || i == 13 || i == 160;
    }

    public static boolean ˏ(int i) {
        return Character.getType(i) == 16 && (i == 8203 || i == 8204 || i == 8205 || i == 173);
    }

    public static String ˎ(String str) {
        StringBuilder ˏ = ˏ();
        ˋ(ˏ, str, false);
        return ˎ(ˏ);
    }

    public static void ˋ(StringBuilder stringBuilder, String str, boolean z) {
        int length = str.length();
        int i = 0;
        Object obj = null;
        Object obj2 = null;
        while (i < length) {
            int codePointAt = str.codePointAt(i);
            if (ˊ(codePointAt)) {
                if (!(z && r0 == null) && r2 == null) {
                    stringBuilder.append(' ');
                    int i2 = 1;
                }
            } else if (!ˏ(codePointAt)) {
                stringBuilder.appendCodePoint(codePointAt);
                int i3 = 1;
                obj2 = null;
            }
            i += Character.charCount(codePointAt);
        }
    }

    public static boolean ˊ(String str, String... strArr) {
        for (String equals : strArr) {
            if (equals.equals(str)) {
                return true;
            }
        }
        return false;
    }

    public static boolean ˏ(String str, String[] strArr) {
        return Arrays.binarySearch(strArr, str) >= 0;
    }

    public static URL ˎ(URL url, String str) throws MalformedURLException {
        if (str.startsWith("?")) {
            str = url.getPath() + str;
        }
        if (str.indexOf(46) == 0 && url.getFile().indexOf(47) != 0) {
            url = new URL(url.getProtocol(), url.getHost(), url.getPort(), "/" + url.getFile());
        }
        return new URL(url, str);
    }

    public static String ॱ(String str, String str2) {
        try {
            try {
                return ˎ(new URL(str), str2).toExternalForm();
            } catch (MalformedURLException e) {
                return "";
            }
        } catch (MalformedURLException e2) {
            return new URL(str2).toExternalForm();
        }
    }

    public static StringBuilder ˏ() {
        StringBuilder stringBuilder;
        synchronized (ˏ) {
            if (ˏ.empty()) {
                stringBuilder = new StringBuilder(8192);
            } else {
                stringBuilder = (StringBuilder) ˏ.pop();
            }
        }
        return stringBuilder;
    }

    public static String ˎ(StringBuilder stringBuilder) {
        gbj.ˋ((Object) stringBuilder);
        String stringBuilder2 = stringBuilder.toString();
        if (stringBuilder.length() > 8192) {
            stringBuilder = new StringBuilder(8192);
        } else {
            stringBuilder.delete(0, stringBuilder.length());
        }
        synchronized (ˏ) {
            ˏ.push(stringBuilder);
            while (ˏ.size() > 8) {
                ˏ.pop();
            }
        }
        return stringBuilder2;
    }
}
